package com.dt.platform.generator.module.hr;


import com.dt.platform.constants.db.HrTables;
import com.dt.platform.constants.enums.common.StatusEnableEnum;
import com.dt.platform.constants.enums.hr.LearnTaskStatusEnum;
import com.dt.platform.constants.enums.hr.PaperTaskResultStatusEnum;
import com.dt.platform.constants.enums.hr.PaperTaskStatusEnum;
import com.dt.platform.domain.hr.*;
import com.dt.platform.generator.config.Config;
import com.dt.platform.hr.page.PaperTaskPageController;
import com.dt.platform.proxy.hr.LearnTaskServiceProxy;
import com.dt.platform.proxy.hr.PaperTaskServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;


public class APapeTaskGtr extends BaseCodeGenerator {
    public APapeTaskGtr() {
        super(HrTables.HR_PAPER_TASK.$TABLE,"811268060357853184");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(HrTables.HR_PAPER_TASK.ID).basic().hidden(true);

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"user","user","user");
        cfg.getPoClassFile().addSimpleProperty(String.class,"queryRole","queryRole","queryRole");


        cfg.getPoClassFile().addSimpleProperty(Paper.class,"paper","paper","paper");
        cfg.getPoClassFile().addSimpleProperty(PaperRelease.class,"paperRelease","paperRelease","paperRelease");
        cfg.getPoClassFile().addListProperty(PaperQuestion.class,"paperQuestionList","paperQuestionList","paperQuestionList");
        cfg.getPoClassFile().addListProperty(PaperQuestionRel.class,"paperQuestionRealList","paperQuestionRealList","paperQuestionRealList");

        cfg.view().field(HrTables.HR_PAPER_TASK.NAME).form().validate().required();
        cfg.view().field(HrTables.HR_PAPER_TASK.START_TIME).form().dateInput().type(DatePickerType.datetime).format("yyyy-MM-dd HH:mm:ss").search().range();
        cfg.view().field(HrTables.HR_PAPER_TASK.FINISH_TIME).form().dateInput().type(DatePickerType.datetime).format("yyyy-MM-dd HH:mm:ss").search().range();
        cfg.view().field(HrTables.HR_PAPER_TASK.CREATE_TIME).form().dateInput().type(DatePickerType.datetime).format("yyyy-MM-dd").search().range();

        cfg.view().field(HrTables.HR_PAPER_TASK.NAME).search().fuzzySearch();

        cfg.view().search().inputLayout(
                new Object[]{
                        HrTables.HR_PAPER_TASK.PAPER_STATUS,
                        HrTables.HR_PAPER_TASK.USER_ID,
                        HrTables.HR_PAPER_TASK.NAME,
                        HrTables.HR_PAPER_TASK.CREATE_TIME,
                }
        );

        cfg.view().field(HrTables.HR_PAPER_TASK.USER_ID).table().fillBy("user","name");
        cfg.view().field(HrTables.HR_PAPER_TASK.USER_ID).form().readOnly().form()
                .button().chooseEmployee(true).search().selectMuliti(false);

        cfg.view().list().disableBatchDelete();
      //  cfg.view().field(HrTables.HR_PAPER_TASK.START_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.PAPER_ID).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.UPDATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.CREATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_TASK.PAPER_RELEASE_ID).form().table().disable(true);


        cfg.view().field(HrTables.HR_PAPER_TASK.STATUS).form()
              .radioBox().enumType(PaperTaskStatusEnum.class);

        cfg.view().field(HrTables.HR_PAPER_TASK.PAPER_STATUS).form()
                .radioBox().enumType(PaperTaskResultStatusEnum.class);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);


        cfg.view().search().rowsDisplay(1);
        cfg.view().formWindow().width("80%");;
        cfg.view().formWindow().bottomSpace(300);

        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_PAPER_TASK.PAPER_STATUS,
                        HrTables.HR_PAPER_TASK.SCORE,
                        HrTables.HR_PAPER_TASK.START_TIME,
                        HrTables.HR_PAPER_TASK.FINISH_TIME,
                }

        );

        cfg.view().list().addJsVariable("PAPER_RELEASE_ID","[[${paperReleaseId}]]","paperReleaseId");
        cfg.view().list().addJsVariable("ROLE","[[${role}]]","role");

        cfg.view().list().addToolButton("阅卷","evaluatePapers","evaluatePapers");

        cfg.view().list().operationColumn().addActionButton("考试","start","start");

        //cfg.view().list().operationColumn().addActionButton("成绩","paperResult","paperResult");
        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setBpmEventAdaptor(WriteMode.COVER_EXISTS_FILE)
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE) //列表HTML页
                .setExtendJsFile(WriteMode.IGNORE);
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        APapeTaskGtr g=new APapeTaskGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
       // System.out.println("############"+g.getTablePrefix());
       // g.removeByBatchId("801716675761143808");
      //  //生成菜单
       //g.generateMenu(LearnTaskServiceProxy.class, PaperTaskPageController.class);
    }
}
